#pragma once
#include "DirectX.h"
#include "Sprite.h"
#include <fstream>
#include <iostream>
#include <memory>
using namespace std;


//column index constant
#define IMGPATH 1
#define WIDTH 2
#define HEIGHT 3
#define SPRITEPERROW 4
#define COUNT 5
#define ANIRATE 6


class CResourceManager
{
protected:
	DirectX *_directX;
	LPCWSTR _resourceConfigPath;

	LPDIRECT3DTEXTURE9* _textureList;
	char** _imagePathList;
	int** _spriteInfo;

	int _numResource;

public:
	CResourceManager(){};
	CResourceManager(DirectX *dx, LPCWSTR resourcepath);
	~CResourceManager(void);
	
	void LoadImagePath();
	void LoadConfig();
	void LoadResource();

	LPDIRECT3DTEXTURE9 getTexture(int resourceName);
	shared_ptr<Sprite> getSprite(int resourceName);

	char* getConstantName(int Constant);

	char* getLink(int resourceName);

public:
	//GAME OBJECT CONSTANT
		static const int TYPE_MARIO = 1;
        static const int TYPE_MARIO1 = 10;
        static const int TYPE_MARIO2 = 11;
        static const int TYPE_MARIO3 = 12;
						
        static const int TYPE_ENEMIES = 2;
        static const int TYPE_MUSHROOM = 20;
        static const int TYPE_TURTLE = 21;
						 
        static const int TYPE_BUILDING = 3;
        static const int TYPE_BRICK = 30;
        static const int TYPE_STONE = 31;
        static const int TYPE_QUESTIONBOX = 32;
        static const int TYPE_EMPTYBOX = 33;
        static const int TYPE_LEFTLAND = 34;
        static const int TYPE_RIGHTLAND = 35;
        static const int TYPE_MIDLAND = 36;
        static const int TYPE_CHIMNEY3 = 37;
        static const int TYPE_CHECKPOINT = 39;
        static const int TYPE_CHIMNEY1 = 310;
        static const int TYPE_PIT = 38;
						 
        static const int TYPE_SIGHT = 4;
        static const int TYPE_CLOUD = 40;
        static const int TYPE_BARRIER = 41;
        static const int TYPE_GRASS = 42;
        static const int TYPE_HIGHTREE = 43;
        static const int TYPE_SHORTTREE = 44;
        static const int TYPE_UPARROW = 45;
        static const int TYPE_MOUNTAIN = 46;
        static const int TYPE_COLUMN1 = 47;
        static const int TYPE_COLUMN2 = 48;
        static const int TYPE_HOUSE = 49;
						 
        static const int TYPE_BONUS = 5;
        static const int TYPE_FLOWER = 50;
        static const int TYPE_COIN = 51;
        static const int TYPE_FOOD = 52;
        static const int TYPE_STAR = 53;
        static const int TYPE_BRICKWITHCOIN = 54;
        static const int TYPE_BOXWITHCOIN = 55;
        static const int TYPE_BOXWITHMUSHROOM = 56;
		static const int TYPE_BULLET = 1000;


	//SPRITE CONSTANT
	static const int BACKGROUND = 0;

	static const int MARIOSTANDLEFT1 = 1;
	static const int MARIOSTANDRIGHT1 = 2;
	static const int MARIOMOVELEFT1 = 3;
	static const int MARIOMOVERIGHT1 = 4;
	static const int MARIOJUMPLEFT1 = 5;
	static const int MARIOJUMPRIGHT1 = 6;

	static const int MARIOSTANDLEFT2 = 7;
	static const int MARIOSTANDRIGHT2 = 8;
	static const int MARIOMOVELEFT2 = 9;
	static const int MARIOMOVERIGHT2 = 10;
	static const int MARIOJUMPLEFT2 = 11;
	static const int MARIOJUMPRIGHT2 = 12;

	static const int MARIOSTANDLEFT3 = 13;
	static const int MARIOSTANDRIGHT3 = 14;
	static const int MARIOMOVELEFT3 = 15;
	static const int MARIOMOVERIGHT3 = 16;
	static const int MARIOJUMPLEFT3 = 17;
	static const int MARIOJUMPRIGHT3 = 18;

	static const int MARIODIE = 19;

	static const int GOMBAMOVE = 20;
	static const int GOMBAPUSHED = 21;
	static const int GOMBADIE = 22;

	static const int TURBLEMOVELEFT = 23;
	static const int TURBLEMOVERIGHT = 24;
	static const int TURBLEPUSHED = 25;
	static const int TURBLEDIE = 26;

	static const int BRICK = 27;
	static const int BRICKEXP = 28;
	static const int STONE = 29;
	static const int MIDLAND = 30;
	static const int CHIMNEY = 31;

	static const int BULLET = 32;
	static const int MUSHROOMFOOD = 33;
	static const int FLOWER = 34;
	static const int QUESTIONBOX = 35;
	static const int EMPTYBOX = 36;
	static const int COIN = 37;

	static const int CLOUD = 38;
    static const int BARRIER = 39;
    static const int GRASS = 40;
    static const int HIGHTREE = 41;
    static const int SHORTTREE = 42;
    static const int UPARROW = 43;
    static const int MOUNTAIN = 44;
    static const int COLUMN1 = 45;
    static const int COLUMN2 = 46;
    static const int HOUSE = 47;

	static const int MARIOTEXT = 48;
	static const int SCORE = 49;
	static const int COININFO = 50;
	static const int GAMEOVER = 51;

	static const int PIT = 52;
	static const int BAR = 53;

	static const int MAINMENU = 54;
	static const int HELPMENU = 55;
};